// 模拟群组数据
export const mockRooms = [
  {
    id: 1,
    conversationId: 101,
    roomId: 201,
    name: '前端技术交流群',
    description: '讨论Vue、React、Angular等前端技术',
    announcement: '欢迎加入前端技术交流群！请大家遵守群规，文明交流。',
    avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
    ownerId: 1,
    memberCount: 24,
    onlineCount: 5,
    createTime: '2023-05-15 10:30:00'
  },
  {
    id: 2,
    conversationId: 102,
    roomId: 202,
    name: '后端开发群',
    description: '讨论Java、Python、Node.js等后端技术',
    announcement: '本群讨论后端技术，欢迎分享经验和提问。',
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
    ownerId: 2,
    memberCount: 18,
    onlineCount: 3,
    createTime: '2023-05-20 14:20:00'
  },
  {
    id: 3,
    conversationId: 103,
    roomId: 203,
    name: '网络安全交流群',
    description: '讨论网络安全、加密技术等话题',
    announcement: '网络安全无小事，请勿在群内分享敏感信息。',
    avatar: 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png',
    ownerId: 1,
    memberCount: 12,
    onlineCount: 2,
    createTime: '2023-06-05 09:15:00'
  }
]

// 模拟API响应
export const mockRoomApi = {
  // 获取群组列表
  listRooms: () => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          code: 200,
          message: 'success',
          data: mockRooms
        })
      }, 300)
    })
  },
  
  // 创建群组
  createRoom: (data) => {
    return new Promise(resolve => {
      setTimeout(() => {
        const newRoom = {
          id: mockRooms.length + 1 + 10,
          conversationId: 100 + mockRooms.length + 10,
          roomId: 200 + mockRooms.length + 10,
          name: data.name,
          description: data.description,
          announcement: '',
          avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
          ownerId: 1,
          memberCount: 1,
          onlineCount: 1,
          createTime: new Date().toISOString().replace('T', ' ').substring(0, 19)
        }
        mockRooms.push(newRoom)
        resolve({
          code: 200,
          message: 'success',
          data: newRoom
        })
      }, 300)
    })
  },
  
  // 获取群组详情
  getRoomDetail: (id) => {
    return new Promise(resolve => {
      setTimeout(() => {
        const room = mockRooms.find(g => g.id === id)
        resolve({
          code: 200,
          message: 'success',
          data: room
        })
      }, 300)
    })
  },
  
  // 邀请用户加入群聊
  inviteUsers: (data) => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          code: 200,
          message: 'success',
          data: null
        })
      }, 300)
    })
  },
  
  // 退出群聊
  exitRoom: (id) => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          code: 200,
          message: 'success',
          data: null
        })
      }, 300)
    })
  },
  
  // 解散群聊
  disbandRoom: (id) => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          code: 200,
          message: 'success',
          data: null
        })
      }, 300)
    })
  },
  
  // 分页获取群成员
  roomGroupUserPage: (params) => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          code: 200,
          message: 'success',
          data: {
            list: [
              {
                id: 1,
                nickname: '用户1',
                avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
                role: 'owner',
                online: true
              },
              {
                id: 2,
                nickname: '用户2',
                avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
                role: 'member',
                online: true
              },
              {
                id: 3,
                nickname: '用户3',
                avatar: 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png',
                role: 'member',
                online: false
              }
            ],
            total: 3,
            page: params.page || 1,
            page_size: params.page_size || 20
          }
        })
      }, 300)
    })
  },
  
  // 获取群成员统计
  roomGroupUserCount: (params) => {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({
          code: 200,
          message: 'success',
          data: {
            total_count: 3,
            online_count: 2
          }
        })
      }, 300)
    })
  }
} 